{% extends 'TopxiaWebBundle:CourseQuestionManage:question-form-layout.html.twig' %}

{% block question_extra_fields %}

  <div data-role="choices"></div>
  <div id="ckeditor-config" style="display:none;" data-image-upload-url="{{ path('editor_upload', {token:upload_token('course')}) }}" data-image-download-url="{{ path('editor_download', {token:upload_token('course')}) }}"></div>
  <div class="form-group">
    <div class="col-md-2 control-label"></div>
    <div class="col-md-8 controls">
       <button class="btn btn-success btn-sm pull-right" data-role="add-choice" type="button">{{'新增选项'|trans}}</button>
    </div>
  </div>
  <div class="form-group">
    <div class="col-md-2 control-label"><label>{{'不定项选择题'|trans}}</label></div>
      <div class="col-md-8 controls radios">
        {{ radios('uncertain', {'0':'否'|trans, '1':'是'|trans}, question.type|default('choice') == 'uncertain_choice' ? 1 : 0) }}
      </div>
  </div>

  {% if question.metas.choices|default(null) %}
    <script type="text/plain" data-role="choices-data">{{ question.metas.choices|json_encode|raw}}</script>
    <script type="text/plain" data-role="answers-data">{{ question.answer|json_encode|raw}}</script>
  {% endif %}
  <script type="text/x-handlebars-template" data-role="choice-template">
    {% verbatim %}
      <div class="form-group" data-role="choice">
        <div class="col-sm-2 control-label"><label class="choice-label" for="item-input-{{ id }}">选项{{ code }}</label></div>
        <div class="col-sm-8 controls">
          <textarea class="form-control item-input col-md-8" id="item-input-{{ id }}" name="choices[]" data-display="选项内容" data-image-upload-url="{{ imageUploadUrl }}" data-image-download-url="{{ imageDownloadUrl }}">{{ content }}</textarea>
          <p class="mtm">
            <label><input type="checkbox" class="answer-checkbox" {{#if isAnswer }}checked="checked"{{/if}}> 正确答案</label>
          </p>
        </div>
        <div class="col-sm-2" style="padding-left:0;">
          <a class="btn btn-default btn-sm delete-choice mlm" data-role="delete-choice" href="javascript:void(null)"><i class="glyphicon glyphicon-trash"></i></a>
        </div>
      </div>
    {% endverbatim %}
  </script>
{% endblock %}
{# <div id="item-upload-{{ id }}" class="btn btn-default btn-sm webuploader-container" data-target="#item-input-{{ id }}"><i class="glyphicon glyphicon-picture"></i></div>
<div id="item-audio-upload-{{ id }}" class="btn btn-sm btn-default item-audio-upload webuploader-container hide" data-target="#item-input-{{ id }}"><i class="glyphicon glyphicon-volume-up"></i></div> #}
